package pATT.profilingAlgorithm.PersonalSearcher;
/***************************************************************************
 *                              DropLittleWords                            * 
 *                       initial version by: Travis Bauer                  *
 *                      copyright (C) 2001 IGLU Research Group             *
 *                             trbauer@indiana.edu                         *
 ***************************************************************************/
/***************************************************************************
 * The licence for this code is included in LICENSE.txt.  If you did not   *
 * get this file with this distribution, request a copy from               *
 * iglu@cs.indiana.edu                                                     *
 ***************************************************************************/

import java.util.Iterator;



/**
 * Drops any words of length maximumSize or below (default is three).
 *
 * @author <a href="mailto:trbauer@indiana.edu">Travis Bauer</a>
 */
public class DropLittleWords implements DocumentFilter {

  int size=0;

  public DropLittleWords() {}

  public DropLittleWords(int minimumSize) {
    size=minimumSize;
  }

  public Instance applyFilter(Instance i) {
    TermVector v = i.getVector();
    TermVector newv = new TermVector();
    
    for (Iterator it=v.termIterator(); it.hasNext(); ) {
      String s = it.next().toString().trim();
	if ((s.length()>size)&&(s.length()<10)) {
       		newv.put(s,v.get(s));
        }
	else
		if (s.toLowerCase().equals("c"))
		      		newv.put(s,v.get(s));
    }
		i.setVector(newv);
		return i;
  }
}
